<?php
    header('Access-Control-Allow-Origin: *');
    header('Content-Type:text/html;charset=utf-8');
    $con = mysqli_connect("127.0.0.1", "root", "root", "mydb");
    $uid = $_GET['uid'];
    $classId = $_GET['classId'];
    $className = $_GET['className'];
    $classPlace = $_GET['classPlace'];
    $classTime = $_GET['classTime'];
    $sql = "SELECT * FROM lesson WHERE l_id = '$classId';";
    $res = mysqli_query($con,$sql);
    if(mysqli_fetch_row($res)){
        echo 'exist';
    }else{
        $sql1 = "INSERT INTO lesson (l_id,l_name,l_time,l_place,teacher_id) VALUES('$classId','$className','$classTime','$classPlace','$uid');";
        $res1 = mysqli_query($con,$sql1);
        if(mysqli_affected_rows($con) > 0){
            echo 'ok';
        }else{
            echo 'fail';
        }
    }
    mysqli_close($con);
?>